package com.xbongbong.parent.interfaces;

import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.domain.entity.ext.PaasFormDataEntityExt;
import com.xbongbong.paas.pojo.dto.FormDataDeleteBatchDTO;
import com.xbongbong.paas.pojo.vo.FormDataDeleteBatchVO;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.parent.pojo.delete.ErrorDataPojo;

import java.util.List;

/**
 * 删除逻辑，需要实现如下方法
 * @author 吴峰
 * @date 2021/12/27 16:40
 */
public interface BusinessDeleteService<F, D> {

    /**
     * 详情页删除和列表页删除
     * @param formDataDeleteBatchDTO
     * @return
     * @throws XbbException
     */
    FormDataDeleteBatchVO deleteBatch(FormDataDeleteBatchDTO formDataDeleteBatchDTO) throws XbbException;

    /**
     * 校验数据权限(团队权限&共享权限)
     * @param formDataDeleteBatchDTO
     * @throws XbbException
     */
    void validateDataPermission(FormDataDeleteBatchDTO formDataDeleteBatchDTO, F form) throws XbbException;

    /**
     * 工作流详情页删除
     * @param formDataDeleteBatchDTO
     * @return
     * @throws XbbException
     */
    FormDataDeleteBatchVO deleteWorkflow(FormDataDeleteBatchDTO formDataDeleteBatchDTO) throws XbbException;
    /**
     * 业务类型
     * @return
     */
    List<Integer> businessType();

    /**
     * 获取表单
     * @param formDataDeleteBatchDTO
     * @return
     * @throws XbbException
     */
    F getForm(FormDataDeleteBatchDTO formDataDeleteBatchDTO) throws XbbException;

    /**
     * 校验删除权限
     * @param formDataDeleteBatchDTO
     * @throws XbbException
     */
    void validatePermission(FormDataDeleteBatchDTO formDataDeleteBatchDTO) throws XbbException;

    /**
     * 删除数据，此处没有权限判断
     * @param formDataDeleteBatchDTO
     * @param form
     * @return
     * @throws XbbException
     */
    FormDataDeleteBatchVO deleteBatchNoPermission(FormDataDeleteBatchDTO formDataDeleteBatchDTO, F form) throws XbbException;

    /**
     * 删除es中有的数据，但是数据库没有的数据
     * @param dataIdIn
     * @param corpid
     * @return
     * @throws XbbException
     */
    List<D> deleteEsData(FormDataDeleteBatchDTO formDataDeleteBatchDTO, List<Long> dataIdIn, String corpid) throws XbbException;

    /**
     * 返回不允许删除的原因和不允许删除的数据
     * @param formDataDeleteBatchDTO
     * @param list
     * @return
     * @throws XbbException
     */
    ErrorDataPojo notAllowData(FormDataDeleteBatchDTO formDataDeleteBatchDTO, List<D> list) throws XbbException;



    /**
     * 删除数据
     * @param formDataDeleteBatchDTO
     * @param dataIdIn
     * @param corpid
     * @param list
     * @return
     * @throws XbbException
     */
    List<Long> deleteData(FormDataDeleteBatchDTO formDataDeleteBatchDTO, List<Long> dataIdIn, List<D> list, String corpid) throws XbbException;

    /**
     * 记录日志，异步处理
     * @param formDataDeleteBatchDTO
     * @param list
     */
    void log(FormDataDeleteBatchDTO formDataDeleteBatchDTO,  List<D> list, ErrorDataPojo errorDataPojo) throws XbbException;


    /**
     * 删除之后的操作， 低代码、业务规则、工作流等
     * @param dataIdList
     * @param formDataDeleteBatchDTO
     * @param form
     * @throws XbbException
     */
    void deleteAfter(List<Long> dataIdList, FormDataDeleteBatchDTO formDataDeleteBatchDTO, F form) throws XbbException;

    /**
     * 回滚
     * @param corpid
     * @param list
     */
    void rollback(List<Long> list, String corpid);
}
